#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int main()
{
	int n;
	cin >> n;
	int i = 0;
	while (n) {
		arr[i++] = n % 6;
		n /= 6;
	}
	for (int j = i-1; j >= 0; j--) {
		cout << arr[j];
	}
	return 0;
}